<template>
	<view>
		<view class="header-title">
			<uni-icons class="back-icon" type="left" size="20" @tap="back"></uni-icons>
			<text>扫一扫</text>
		</view>
		<mumu-get-qrcode :definition="true" @success='qrcodeSucess' @error="qrcodeError"></mumu-get-qrcode>
	</view>
</template>

<script>
	import mumuGetQrcode from '@/uni_modules/mumu-getQrcode/components/mumu-getQrcode/mumu-getQrcode.vue'
	var scanCode = require('./../../utils/scanCode.js');
	export default {
		components: {
			mumuGetQrcode	
		},
		data() {
			return {
				src: ''
			}
		},
		onLoad() {
	
		},
		mounted() {
		},
		methods: {
			back(){
				uni.navigateBack({})
			},
			qrcodeSucess(data) {
				// uni.showModal({
				// 	title: '成功',
				// 	content: data,
				// 	success: () => {
				// 		uni.navigateBack({})
				// 	}
				// })
				// alert(data)
				scanCode.scanCodeFn(data)
				uni.navigateBack({})
			},
			qrcodeError(err) {
				console.log(err)
				alert(err)
				uni.showModal({
					title: '摄像头授权失败',
					content: '摄像头授权失败，请检测当前浏览器是否有摄像头权限。',
					success: () => {
						uni.navigateBack({})
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.header-title{
		background: #fff;
		height: 88rpx;
		text-align: center;
		line-height: 88rpx;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 12;
		.back-icon{
			position: absolute;
			left: 24rpx;
			top: 50%;
			transform: translateY(-50%);
		}
	}
</style>